home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / MoofWars / Tim's Libraries / Scaling.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.6 KB  |  75 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Scaling.h
  3.  
  4.     Contains:    Scaling implements a standard 2D canvas to draw a set of TGraphics and tiles into.
  5.                 It also provides a set of globals that allow the sprite's location to be relative
  6.                 to a specific camera location.
  7.  
  8.     Written by: Timothy Carroll    
  9.  
  10.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  11.  
  12.                 You may incorporate this Apple sample source code into your program(s) without
  13.                 restriction. This Apple sample source code has been provided "AS IS" and the
  14.                 responsibility for its operation is yours. You are not permitted to redistribute
  15.                 this Apple sample source code as "Apple sample source code" after having made
  16.                 changes. If you're going to re-distribute the source, we require that you make
  17.                 it clear in the source that the code was descended from Apple sample source
  18.                 code, but that you've made changes.
  19.  
  20.     Change History (most recent first):
  21.                 7/2/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  22.                 8/15/96        Timothy Carroll    Initial Release
  23.                 
  24.  
  25. */
  26.  
  27. #ifndef _SCALING_
  28. #define _SCALING_
  29.  
  30. #include <QuickDraw.h>
  31.  
  32. // We define all the world coordinate scaling information here, and also define functions
  33. // for choosing the drawing buffer and clipping to it.  The drawing buffer will be used by
  34. // TGraphic and TTile objects and any other class of offscreen blitters we make in the future.
  35.  
  36.  
  37. // WorldRect32 is a rectangle in 16.16 fixed point coordinates.  FixedPoint coordinates are
  38. // used for all coordinates in the game.  Anything in world coordinates should be converted
  39. // to screen coordinates before being drawn.
  40. // This structure defines a rectangle in 16.16 fixed point coordinates -- these are used as
  41. // the world coordinates for the game, they must be translated into screen coordinates
  42. // before drawing can take place.
  43.  
  44. struct WorldRect32
  45. {
  46.     SInt32 top;
  47.     SInt32 left;
  48.     SInt32 bottom;
  49.     SInt32 right;
  50. };
  51.  
  52. // For the most part, we define a number of globals that can be read freely, but 
  53. // the functions should be called whenever one of these globals needs to be updated.
  54. // This is because more than one global might need to be set, and the functions do the
  55. // right thing.
  56.  
  57.  
  58.  
  59. extern SInt32             gWorldCoordX;
  60. extern SInt32             gWorldCoordY;
  61. extern Rect               gClipRect;
  62. extern SInt32             gClipCenterX;
  63. extern SInt32             gClipCenterY;
  64.  
  65. extern PixMapHandle     gDestPixMap;
  66. extern PixMapHandle     gBackPixMap;
  67. extern unsigned char    *gDestBaseAddr;
  68. extern unsigned char    *gBackBaseAddr;
  69. extern UInt32            gRowBytes;
  70.     
  71. extern void SetDestinationBuffer(PixMapHandle inDestPixMap, PixMapHandle inBackPixMap);
  72. extern void SetBufferClip(Rect *inClipRect);
  73. extern void SetWorldOrigin (SInt32 x, SInt32 y);
  74.  
  75. #endif // _SCALING_